﻿using System.Diagnostics;
using System.IO;
using Commands;
using Commands.Commands;
using System.Collections.Generic;

namespace MyCustomCommandsPlugin
{
    public class CommandsList : CommandListBase
    {
        /// <summary>
        /// Get current computer IP in internet."
        /// </summary>
        [RemoteCommand("Copy new files to external HDD.", "copynew", "cn")]
        public bool CopyNewToExternal()
        {
            var externalHardDrive = @"I:\";
            var dataDrive = @"U:\";

            foreach (var folder in _folders)
                _Move(Path.Combine(dataDrive, folder), Path.Combine(externalHardDrive, folder));

            return true;
        }

        private void _Move(string source, string destination)
        {
            var startInfo = new ProcessStartInfo
                {
                    FileName = "xcopy",
                    Arguments = string.Format("{0} {1} /s /d", source, destination)
                }; 
            
            using (Process exeProcess = Process.Start(startInfo))
            {
                exeProcess.WaitForExit();
            }
        }

        private readonly IEnumerable<string> _folders = new string[]{"Films"};
    }
}
